<?php

/**
 * main actions.
 *
 * @package    explications_informatiques
 * @subpackage main
 * @author     Guimezanes Cyrille
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class headersActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */

  public function executeForbidden(sfWebRequest $request)
  {
	  $this->ref = $request->getReferer();
  }
  public function executeIsedited(sfWebRequest $request)
  {
	  $this->user = $request->getParameter("user");
	  $this->id_asso = $request->getParameter("id_asso");
	  $this->ref = $request->getReferer();
  }
  public function executeModepanel(sfWebRequest $request)
  {
	$this->forward404Unless($this->getUser()->hasCredential("PANEL_MODE"),"headers","forbidden");
	 
    if ($this->getUser()->hasCredential("MOD_NEWS"))
	{
	      $q = Doctrine_Query::create()
		->from('news n')
		->where('n.online = ?', '1')
		->orderBy('n.idnews desc')
		->limit(10);
		$this->newss = $q->execute();
	}
	if ($this->getUser()->hasCredential("MOD_REVISION"))
	{
	  $q = Doctrine_Query::create()
	 	->from('Assoplatform c')
		->leftJoin('c.Articles')
		->leftJoin('c.Commentaires')
		->leftJoin('c.Platform')
		->leftJoin('c.Platform_4')
		->where("c.view_by_mode = ?","0");
	 $this->articles =  $q->execute();
	}
	 if ($this->getUser()->hasCredential("MOD_REVISION"))
	{
	 $q = Doctrine_Query::create()
	 	->from('revisions c')
		->leftJoin('c.SfGuardUserProfile f')
		->leftJoin('f.User')
		->leftJoin('c.Assoplatform d')
		->leftJoin('d.Articles')
		->where("c.validate = ?","0");
	 $this->revisions =  $q->execute();
	}
	if ($this->getUser()->hasCredential("MOD_USER"))
	{
	 $q = Doctrine_Query::create()
	 	->from('SfGuardUserProfile c')
		->leftJoin('c.User')
		->where("c.view_by_mode = ?","0");
	 $this->membres =  $q->execute();
	}
	if ($this->getUser()->hasCredential("MODERATION_ALERT"))
	{
	 $q = Doctrine_Query::create()
	 	->from('alerts c')
		->leftJoin('c.SfGuardUserProfile d')
		->leftJoin('c.Assoplatform e')
		->leftJoin('e.Articles')
		->leftJoin('c.Commentaires')
		->leftJoin('d.User')
		->where("c.view_by_mode = ?","0");
	 $this->alerts =  $q->execute();
	}
	if ($this->getUser()->hasCredential("MOD_LEXIQUE"))
	{
	 $q = Doctrine_Query::create()
	 	->from('lexiquemot c')
		->where("c.view_by_mode = ?","0");
	 $this->words =  $q->execute();
	}
	if ($this->getUser()->hasCredential("MODERATION_DEFS"))
	{
	 $q = Doctrine_Query::create()
	 	->from('lexiquedefinition c')
		->leftJoin('c.Lexiquemot')
		->where("c.view_by_mode = ?","0");
	 $this->defis =  $q->execute();
	}
  }
}
